package com.example.administrator.fangbook.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import com.example.administrator.fangbook.utils.StateViewSet;

import butterknife.ButterKnife;

/**
 * 作者 ： liyinqing on 2018/11/9 0009
 * 邮箱 ：yinqing_521@163.com
 * 1、提取title；
 * 2、设置状态栏；
 * 3、封装View的初始化
 */
public abstract class BaseActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        StateViewSet.setStateView(this, StateViewSet.StateIndicate.STATE_LUCENCY,getIsHideState());
        super.onCreate(savedInstanceState);
        if (getLayoutId() > 0) {
            setContentView(getLayoutId());
        } else {
            finish();
        }
        ButterKnife.bind(this);
        initView(savedInstanceState);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ButterKnife.unbind(this);
    }

    /**
     * 是否显示状态栏
     * @return
     */
    protected abstract boolean getIsHideState();


    /**
     * 初始化View
     *
     * @param savedInstanceState
     */
    protected abstract void initView(Bundle savedInstanceState);

    /**
     * 绑定View
     *
     * @return
     */
    protected abstract int getLayoutId();
}
